package clsz;

import org.frameworkset.tran.DataStream;
import org.frameworkset.tran.db.input.es.DB2ESImportBuilder;

public class ESImportWatch_Times {
    public static void main(String[] args) {
        DB2ESImportBuilder importBuilder = DB2ESImportBuilder.newInstance();

        importBuilder.setDbName("cateyes_data")
                .setDbDriver("com.mysql.cj.jdbc.Driver")
                .setDbUrl("jdbc:mysql://localhost:3306/cateyes_data?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8")
                .setDbUser("root")
                .setDbPassword("root")
                .setUsePool(false);

        // 将查询结果导入 ElasticSearch
        importBuilder.setSql("select * from `watch_times`");
        // ElasticSearch 配置
        importBuilder
                .setIndex("watch_times")
                .setIndexType("_doc")
                .setRefreshOption(null)
                .setUseJavaName(false)
                .setBatchSize(5000)
                .setJdbcFetchSize(10000);
        // 开始导入数据
        DataStream dataStream = importBuilder.builder();
        dataStream.execute();
    }
}
